﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

///爱问命名空间
namespace Tong.IAsk
{
    /// <summary>
    /// 爱问调用方法通用类 
    /// 爱问及数据操作字符串操作类
    /// </summary>
    public class IaskDataOrstr
    {




    /// <summary>
    /// 数据操作通用类 实例 TextData
    /// </summary> 
     TongUse TextData = new TongUse();

    /// <summary>
    /// 系统安装绝对路径
    /// </summary>
     string Abs_Path = TongUse.SysPath;

    /// <summary>
    /// 用户存放数据的临时表
    /// </summary>
    DataTable MyDt = new DataTable();


    /// <summary>
    /// 站点通用方法类
    /// </summary>
    Tong.ThisSiteUse.SiteTong TextThisSite = new Tong.ThisSiteUse.SiteTong();



    /// <summary>
    /// 得到当前页面文件名
    /// </summary>
    /// <param name="pagesurl"></param>
    /// <returns></returns>
    public string GetCurrentPage(string pagesurl)
    {
        try
        {
            return TextData.CurrentPage.Replace("?"+TextData.UrlData, "");
        }
        catch
        {
            return TextData.CurrentPage;
        }
    }

        /// <summary>
        /// 爱问问题状态
        /// </summary>
        /// <param name="lx">问题状态的值</param>
        /// <returns>爱问问题状态</returns>
        public string IakGetAskState(string lx)
        {
            if (lx == "1")
            {
                return "<img src=\"/Iask/user/images/jiejue.gif\"/>";//解决中
            }
            if (lx == "2")
            {
                return "已解决";
            }
            if (lx == "0")
            {
                return "关闭";
            }



            return "";

        }

        /// <summary>
        /// 爱问问题状态 输出图片
        /// </summary>
        /// <param name="lx">问题状态的值</param>
        /// <returns>爱问问题状态</returns>
        public string IakGetAskStateOutImg(string lx)
        {
            if (lx == "1")//未解决
            {
                return "<img src=\"" + Abs_Path + "IAsk/User/images/hao.gif\">";
            }
            if (lx == "2")//已解决
            {
                return "<img src=\"" + Abs_Path + "IAsk/User/images/gou.gif\">";
            }
            if (lx == "0")
            {
                return "关闭";
            }

            return "";

        }


        /// <summary>
        /// 爱问用户类型
        /// </summary>
        /// <param name="lx">用户类型ID</param>
        /// <returns>爱问用户类型</returns>
        public string IakGetUserState(string lx)
        {
            if (lx == "1")
            {
                return "会员";
            }
            if (lx == "2")
            {
                return "专家";
            }
            if (lx == "3")
            {
                return "可操作的会员";
            }
            if (lx == "4")
            {
                return "可操作的专家";
            }
            if (lx == "0")
            {
                return "关闭";
            }

            return "";

        }

        /// <summary>
        /// 爱 问 回答 的 分类
        /// </summary>
        /// <param name="lx">回答类型 1为最好的答案</param>
        /// <returns></returns>
        public string IaskGetQueryState(string lx)
        {
            if (lx == "1")
            {
                return "最佳答案";
            }
            if (lx == "2")
            {
                return "评论";
            }
            
            return "";
        }

        /// <summary>
        /// 爱 问 回答 的 分类
        /// </summary>
        /// <param name="lx">回答类型 1为最好的答案</param>
        /// <returns></returns>
        public string IaskGetQuestionStateOutImg(string lx)
        {
            if (lx == "1")
            {
                return "<img src=\"" + Abs_Path + "IAsk/User/images/qi.gif\">";
            }
            if (lx == "2")
            {
                return "评论";
            }
            

            return "";
        }

        // + MyDt.Rows[0][0].ToString().Trim()).Tables[0];//我的问题
        /// <summary>
        /// 传入问题ID 返回 对应问题ID的DataTable
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public DataTable IaskGetQuestionTable(string id)
        {
            id = id.Trim();
            try
            {
                int.Parse(id.Trim());
            }
            catch//如果问题id 不是数字
            {
                id = "0";
            }

            MyDt = TextData.SqlataSet("select * from [ask_query] where  ask_query_id="  + id).Tables[0];
            return MyDt;
            MyDt.Clear();
            MyDt.Dispose();
            GC.Collect();//回收LJ

        }

        /// <summary>
        /// 传入问题ID 得到问题的 状态 如果是解决中的话 返回 “离问题结束还有 N 天”
        /// </summary>
        /// <param name="id">问题ID</param>
        /// <returns></returns>
        public String IaskGetQuestionStateLx(string id)
        {
            string sstr = "";
            int days=15;//问题结束的天数
            id = id.Trim();
            try
            {
                int.Parse(id.Trim());
                MyDt = TextData.SqlataSet("select ask_query_time,ask_query_state from [ask_query] where  ask_query_id=" + id).Tables[0];//读出时间与状态
                try
                {
                    if (MyDt.Rows[0]["ask_query_state"].ToString().Trim() == "1")//解决中
                    {
                        //问题状态
                        if ((DateTime.Now - DateTime.Parse(MyDt.Rows[0]["ask_query_time"].ToString().Trim())).Days <= days)
                        {
                            return "离问题结束还有 " + (days - (DateTime.Now - DateTime.Parse(MyDt.Rows[0]["ask_query_time"].ToString().Trim())).Days) + " 天";
                        }

                        else
                        {
                            //问题过期
                            if ((DateTime.Now - DateTime.Parse(MyDt.Rows[0]["ask_query_time"].ToString().Trim())).Days > days)
                            {
                                TextData.SqlDataSave("Update [ask_query] Set ask_query_state=0  where ask_query_id=" + id + " ");//关闭问题
                            }
                            else
                            {
                                return IakGetAskStateOutImg(MyDt.Rows[0]["ask_query_state"].ToString().Trim());//返回类型
                            }
                        }

                    }
                }
                catch//如果读取问题出错
                {
                    MyDt.Clear();
                    MyDt.Dispose();
                    GC.Collect();//回收LJ
                    return "";
                    
                }
            }
            catch//如果问题id 不是数字
            {
                id = "0";
            }


            return sstr;

            

        }
        

        /// <summary>
        /// 传入用户ID 返回回 对应用户ID的DataTable
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public DataTable IaskGetUseTable(string id)
        {
            id = id.Trim();
            try
            {
                int.Parse(id.Trim());
            }
            catch//如果用户id 不是数字
            {
                id = "0";
            }

            MyDt = TextData.SqlataSet("select * from [Ask_user] where askuser_id=" + id).Tables[0];
            return MyDt;
            MyDt.Clear();
            MyDt.Dispose();
            GC.Collect();//回收LJ

        }

        /// <summary>
        /// 传入用户名 返回 对应用户名的 DataTable
        /// </summary>
        /// <param name="UserName">用户名 String型</param>
        /// <returns></returns>
        public DataTable IaskGetUseTableByUserName(string UserName)
        {
            UserName = UserName.Trim();
            
            if(UserName!="")
            {
                MyDt = TextData.SqlataSet("select * from [Ask_user] where askuser_Name ='" + UserName+"'").Tables[0];
            }
            return MyDt;
            MyDt.Clear();
            MyDt.Dispose();
            
            GC.Collect();//回收LJ

        }

        /// <summary>
        /// 传入级别ID 返回回 对应的 用户级别 同时跟据用户积分更新用户级别 DataTable
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public DataTable IaskGetLvTable(string id)
        {
            id = id.Trim();
            try
            {
                int.Parse(id.Trim());
            }
            catch//如果用户id 不是数字
            {
                id = "0";
            }

 
            

            //查找用户级别
            MyDt = TextData.SqlataSet("select * from [Ask_LV] where ask_Lv_id  =" + id).Tables[0];
            return MyDt;
            MyDt.Clear();
            MyDt.Dispose();
            GC.Collect();//回收LJ

        }




        /// <summary>
        /// 传入用户ID更新用户级别
        /// </summary>
        /// <param name="用户ID">用户id</param>
        public void Iask传入用户ID更新用户级别(string 用户ID)
        { 
            //得到所有用户级别
            DataTable UseTable = new DataTable();
            UseTable = TextData.SqlataSet("select * from [Ask_LV] ").Tables[0];
            int feng = int.Parse(IaskGetUseTable(用户ID).Rows[0]["askuser_feng"].ToString());//用户积分
            
            for (int i = 0; i < UseTable.Rows.Count; i++)
            { 
                //得到用户级别
                //如果用户的分高于等级分
                if (feng >= int.Parse(UseTable.Rows[i]["askuser_feng"].ToString()))
                {
                    TextData.SqlDataSave("update [Ask_user] Set askuser_LV  ='" + UseTable.Rows[i][0].ToString() + "'  where askuser_id=" + 用户ID);//更新用户级别
                }
               
            }

        }


        /// <summary>
        /// 传入 爱问分类ID 得到 爱问分类生成 目录
        /// </summary>
        /// <param name="id">传入 爱问分类ID</param>
        /// <returns></returns>
        public String IaskGetColumnDirLink(string id)
        {
            try
            {
                if (int.Parse(id).ToString() != "")
                {
                    return TextData.SqlataSet("select CX_Column_Directory from [ask_Column] where CX_Column_id =" + id).Tables[0].Rows[0][0].ToString();
                }
                else
                {
                    return "";
                }
            }
            catch
            {
                return "";
            }
        }

        /// <summary>
        /// 传入 爱问分类ID 得到 爱问分类 数据的 Get 文件 及参数
        /// </summary>
        /// <param name="id">传入 栏目ID</param>
        /// <returns></returns>
        public String IaskGetColumnDirPage(string id)
        {
            try
            {
                if (int.Parse(id).ToString() != "")
                {
                    DataTable ColumnDirPage = new DataTable();
                    ColumnDirPage = TextData.SqlataSet("select CX_Column_ItemTemplate_Url,CX_Column_ItemTeplate_Parame from [ask_Column] where CX_Column_id =" + id).Tables[0];
                    return ColumnDirPage.Rows[0]["CX_Column_ItemTemplate_Url"].ToString() + ColumnDirPage.Rows[0]["CX_Column_ItemTeplate_Parame"].ToString();
                    ColumnDirPage.Dispose();
                }
                else
                {
                    return "";
                }
            }
            catch
            {
                return "";
            }
        }

        /// <summary>
        ///传入 爱问分类ID 得到 爱问分类 数据的表
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public DataTable IaskGetColumnTable(string id)
        {
            DataTable ColumnDirPage = new DataTable();
            try
            {
               
                if (int.Parse(id).ToString() != "")
                {
                    
                    ColumnDirPage = TextData.SqlataSet("select * from [ask_Column] where CX_Column_id =" + id).Tables[0];
                    return ColumnDirPage;
                   
                    ColumnDirPage.Dispose();
                }
                else
                {
                    return ColumnDirPage;
                }
            }
            catch
            {
                return ColumnDirPage;
            }
        }

        /// <summary>
        /// 传入问题ID 得到问题的回答表
        /// </summary>
        /// <param name="QestionID">问题ID</param>
        /// <returns></returns>
        public DataTable IaskGetQuestionAnswerS(string QestionID)
        {
            DataTable ColumnDirPage = new DataTable();
            try
            {

                if (int.Parse(QestionID).ToString() != "")
                {

                    ColumnDirPage = TextData.SqlataSet("select * from [ask_answer] where ask_answer_Lx<>2 and ask_query_id =" + QestionID + "order  by ask_answer_Lx desc").Tables[0];//ask_answer_Lx   1是最佳答案  0为一般,2为评论 15天后或关闭后为评论
                    return ColumnDirPage;

                    ColumnDirPage.Dispose();
                }
                else
                {
                    return ColumnDirPage;
                }
            }
            catch
            {
                return ColumnDirPage;
            }
        }

        /// <summary>
        /// 传入问题ID 得到问题的评论表
        /// </summary>
        /// <param name="QestionID">问题ID</param>
        /// <returns></returns>
        public DataTable IaskGetQuestionCritique(string QestionID)//Critique 评论 critique 
        {
            DataTable ColumnDirPage = new DataTable();
            try
            {

                if (int.Parse(QestionID).ToString() != "")
                {

                    ColumnDirPage = TextData.SqlataSet("select * from [ask_answer] where ask_answer_Lx=2 and ask_query_id =" + QestionID).Tables[0];//ask_answer_Lx   1是最佳答案  0为一般,2为评论 15天后或关闭后为评论
                    return ColumnDirPage;

                    ColumnDirPage.Dispose();
                }
                else
                {
                    return ColumnDirPage;
                }
            }
            catch
            {
                return ColumnDirPage;
            }
        }

        /// <summary>
        /// 防此SQL注入
        /// </summary>
        public void CheckFormUrl()
        {
            Tong.Check.Check Check = new Tong.Check.Check();
            Check.CheckStr();
        }

        /// <summary>
        /// 传入问题ID  是否为推荐问题
        /// </summary>
        /// <param name="QuestionID">问题ID</param>
        /// <returns></returns>
        public bool 是否为推荐问题(string QuestionID)
        { 
            bool xxxvalue =false;

            try
            {
                //推荐问题
                if (TextData.SqlataSet("select ask_query_commend from [ask_query] where ask_query_id=" + QuestionID).Tables[0].Rows[0][0].ToString().Trim() == "1")
                {
                    xxxvalue = true;
                }
            }
            catch
            { 
            }

            return xxxvalue;
        }


        /// <summary>
        /// 推荐问题
        /// </summary>
        /// <param name="xx">推荐问题ID</param>
        /// <param name="showlx">显示类型0为文字</param>
        /// <returns></returns>
        public string Tuijianwenti(string xx, int showlx)
        {
            string xxxvalue = "";
            if (是否为推荐问题(xx))
            {
                if (showlx == 0)
                {
                    xxxvalue = "推荐";
                }
            }
            return xxxvalue;
        }


        public String Name(string usename)
        {
            usename = usename.Trim();
            if (usename == "fg")
            {
                usename = "匿名";
            }

            return usename;
        }





        /// <summary>
        /// 得到这个栏目下所有的子栏目 格式为 idā名á 第二个
        /// </summary>
        /// <param name="CloumnID">栏目ID</param>
        public void ShowClass(int CloumnID)
        {
            string Showbockisql;
            Showbockisql = "select * from [ask_Column] where CX_Column_followid=" + CloumnID + " order by CX_Column_Sort desc,CX_Column_id desc";
            /// <summary>
            /// 用于保存栏目的临时表
            /// </summary>
            DataTable ShowbokckTablue = new DataTable();
            ShowbokckTablue = TextData.SqlataSet(Showbockisql).Tables[0];
            for (int Showbocki = 0; Showbocki < ShowbokckTablue.Rows.Count; Showbocki++)
            {
                if (CloumnID == 0)//一级栏目
                {
                    //得到指定栏目名称
                    Xtext += "\r\n<div class=\"list-boxmenu\"><h1><a href=\"/Iask/Html/C/" + ShowbokckTablue.Rows[Showbocki]["CX_Column_id"].ToString() + ".html\">" + ShowbokckTablue.Rows[Showbocki]["CX_Column_Name"].ToString() + " </a></h1>\r\n\t<ul>\r\n";
                }
                else
                {
                    //如果下面有子分类
                    if (TextData.SqlataSet("select * from [ask_Column] where CX_Column_followid=" + ShowbokckTablue.Rows[Showbocki]["CX_Column_id"].ToString() + " order by CX_Column_Sort desc,CX_Column_id desc").Tables[0].Rows.Count > 0)
                    {
                        Xtext += "\r\n\t</ul><div class=\"list-boxmenu\"><h1><a href=\"/Iask/Html/C/" + ShowbokckTablue.Rows[Showbocki]["CX_Column_id"].ToString() + ".html\">" + ShowbokckTablue.Rows[Showbocki]["CX_Column_Name"].ToString() + " </a></h1>\r\n\t<ul>\r\n";
                    }
                    else
                    {
                        Xtext += "\t\t<li><a href=\"/Iask/Html/C/" + ShowbokckTablue.Rows[Showbocki]["CX_Column_id"].ToString() + ".html\">" + ShowbokckTablue.Rows[Showbocki]["CX_Column_Name"].ToString() + " </a></li>\r\n";

                        if (ShowbokckTablue.Rows.Count == Showbocki + 1)
                        {
                            Xtext += "</ul>";
                        }
                    }
                }
                ShowClass(int.Parse(ShowbokckTablue.Rows[Showbocki]["CX_Column_id"].ToString()));
            }

        }

        string Xtext = "";

        /// <summary>
        /// 在调用 ShowClass(分类ID)后用此方法得到数据
        /// </summary>
        public string Xtext1
        {
            get
            {

                string sss = Xtext;
                Xtext = "";
                return sss.Replace("</ul>","</ul>\r\n</div>");

            }
        }


        //制作导行类
        /// <summary>
        ///  导行方法  支择问题 ,问题分类
        /// 传入得到的ID  入得当前类型 是问题表的问题 还分类表下面的直接表
        /// </summary>
        /// <param name="CurrID">传入当前得到的ID</param>
        /// <param name="LX">问题类型QuesID&#13;分类直属表Column&#13; </param>
        /// <returns></returns>
        public string SiteGetWebSiteMap(string CurrID, string LX)
        {
            //临时数据表
            DataTable WebSiteTable = new DataTable();
            //数据临时表
            DataTable WEBSiteTable = new DataTable();

            //web导行的字符串 
            string websitetext = "";

            ///新闻ID;
            string NewsIDWebSite = "";
            ///新闻分类ID
            string NewsLxIdWebSite = "";

            //栏目ID
            string ColumnidWebSite = "";

            //新闻生成文件名
            string NewsCrtFileName = "";

            //当前栏目级别
            int CurrColumnIDLv = 0;

            string Dir="/Iask/Html/"; //显示栏目的目录

            if (LX == "QuesID")//问题类型ＩＤ
            {
                NewsLxIdWebSite = CurrID;////传入问题　类型ＩＤ

                //开始得到栏目ID 
                WebSiteTable = TextData.SqlataSet("select * FROM [ask_query] where [ask_query_id]=" + NewsLxIdWebSite).Tables[0];

                string questionname = WebSiteTable.Rows[0]["ask_query_name"].ToString();

                try
                {

                    ColumnidWebSite = WebSiteTable.Rows[0]["Coulmn_id"].ToString();//得到栏目 ID
                    //当前栏目级别
                    CurrColumnIDLv = SiteGetColumnLv(0, int.Parse(ColumnidWebSite));

                    WebSiteTable = TextData.SqlataSet("select *  FROM [ask_Column] where CX_Column_id=" + ColumnidWebSite).Tables[0];
                    //一级一级的得到栏目
                    for (int i = CurrColumnIDLv; i >= 0; i--)
                    {
                        if (i == 0)//如果是当前栏目ID的栏目
                        {
                            websitetext += "<a href="+Dir+"C/" + WebSiteTable.Rows[0]["CX_Column_id"].ToString()+".html>" + WebSiteTable.Rows[0]["CX_Column_Name"].ToString() + "</a>";

                        }
                        else
                        {
                            WEBSiteTable = GetTopCloumns(ColumnidWebSite, i);
                            websitetext += "<a href=" + Dir + "C/" + WEBSiteTable.Rows[0]["CX_Column_id"].ToString() + ".html>" + WEBSiteTable.Rows[0]["CX_Column_Name"].ToString() + "</a>&gt;&gt;";
                        }
                    }


                    websitetext += NewsCrtFileName;
                    websitetext = websitetext + "&gt;&gt;<a href=" + Dir + CurrID + ".html>" + questionname + "</a>";
                }
                catch (Exception ex)
                {
                    websitetext = ex.Message;
                }
            }

            if (LX == "Column")//直接是栏目ID
            {
                //try
                //{
                    ColumnidWebSite = CurrID;//得到栏目 ID
                    //当前栏目级别
                    CurrColumnIDLv = SiteGetColumnLv(0, int.Parse(ColumnidWebSite));

                    WebSiteTable = TextData.SqlataSet("select *  FROM [ask_Column] where CX_Column_id=" + ColumnidWebSite).Tables[0];
                    //一级一级的得到栏目
                    for (int i = CurrColumnIDLv; i >= 0; i--)
                    {
                        if (i == 0)//如果是当前栏目ID的栏目
                        {
                            websitetext += "<a href=" + Dir + "C/" + WebSiteTable.Rows[0]["CX_Column_id"].ToString() + ".html>" + WebSiteTable.Rows[0]["CX_Column_Name"].ToString() + "</a>";

                        }
                        else
                        {
                            WEBSiteTable = GetTopCloumns(ColumnidWebSite, i);
                            websitetext += "<a href=" + Dir +"C/"+ WEBSiteTable.Rows[0]["CX_Column_id"].ToString() + ".html>" + WEBSiteTable.Rows[0]["CX_Column_Name"].ToString() + "</a>&gt;&gt;";
                        }

                    }
                    websitetext += NewsCrtFileName;
                //}
                //catch (Exception ex)
                //{
                //    websitetext = ex.Message;
                //}
            }
            return "<a href=\"" + "/Iask/" + "\">爱问首页</a>&gt;&gt;" + websitetext;
        }



        /// <summary>
        /// 当前循环栏目的级别
        /// </summary>
        int GetTopCloumnsii = 0;

        /// <summary>
        /// 指定栏目的返回dataTable
        /// </summary>
        DataTable GetTopCloumnsReturnTable = new DataTable();//返回数据的DataTable;

        /// <summary>
        /// 得到指定栏目 的指定 级别的 父栏目
        ///  </summary>
        /// <param name="PointCloumnID">指定栏目ID</param>
        /// <param name="ShowCloumnLv">指定 父栏目 相对于此栏目的逆向级别  以 0 开始</param>
        /// <returns></returns>
        public DataTable GetTopCloumns(string PointCloumnID, int ShowCloumnLv)
        {

            string GetTopCloumnssql = "";
            DataTable GetTopCloumns_DataTable = new DataTable();

            GetTopCloumnssql = "select * from [ask_Column] where CX_Column_id=" + PointCloumnID + " order by CX_Column_Sort desc,CX_Column_id desc ";//得到栏目下的栏目
            GetTopCloumns_DataTable = TextData.SqlataSet(GetTopCloumnssql).Tables[0];//创建 DataTable 

            //子循环
            for (int GetTopCloumnsi = 0; GetTopCloumnsi < GetTopCloumns_DataTable.Rows.Count; GetTopCloumnsi++)
            {

                GetTopCloumnsii = GetTopCloumnsii + 1;
                if (ShowCloumnLv >= GetTopCloumnsii && GetTopCloumns_DataTable.Rows[GetTopCloumnsi]["CX_Column_followid"].ToString() != "0")
                {
                    //栏目ID 
                    GetTopCloumnssql = "";
                    GetTopCloumnssql = " select * from [ask_Column] where   CX_Column_id=" + GetTopCloumns_DataTable.Rows[GetTopCloumnsi]["CX_Column_followid"].ToString() + " order by CX_Column_Sort desc,CX_Column_id desc";
                    GetTopCloumnsReturnTable = TextData.SqlataSet(GetTopCloumnssql).Tables[0];//得到当前表
                    GetTopCloumns(GetTopCloumns_DataTable.Rows[GetTopCloumnsi]["CX_Column_followid"].ToString(), ShowCloumnLv);//调用自己显示THML
                }

                GetTopCloumnsii -= 1;
            }
            return GetTopCloumnsReturnTable;
        }

        /// <summary>
        /// 当前栏目ID
        /// </summary>
        int SiteGetColumnLvTempCloumnID = 0;

        /// <summary>
        /// 临时用于得到级别的变量
        /// </summary>
        int SiteGetColumnLvss = 0;
        /// <summary>
        /// 栏目ID的级别
        /// </summary>
        int SiteGetColumnLvii = 0;

        /// <summary>
        /// 传入栏目ID 得到栏目级别
        /// </summary>
        /// <param name="select">传入 0 </param>
        /// <param name="PointCloumnID">要指定显示的ID</param>
        /// <![CDATA[
        /// 用法 (SiteGetColumnLv(0, 328)
        /// ]]>
        /// <returns></returns>
        public int SiteGetColumnLv(int select, int PointCloumnID)
        {
            string sql;
            int i = 0;
            if (SiteGetColumnLvTempCloumnID != PointCloumnID)
            {
                SiteGetColumnLvTempCloumnID = PointCloumnID;
                SiteGetColumnLvss = 0;
                SiteGetColumnLvii = 0;
            }
            DataTable SiteGetColumnLvMyDt = new DataTable();
            sql = "Select * From ask_Column where CX_Column_LX<>3 and CX_Column_followid =" + select + " order by CX_Column_id desc";
            try
            {
                SiteGetColumnLvMyDt = TextData.SqlataSet(sql).Tables[0];//创建DataTable MyDt
            }
            catch (Exception ex)
            {
                TextData.Err(ex.Message);

            }
            for (i = 0; i < SiteGetColumnLvMyDt.Rows.Count; i++)//遁环记录集
            {
                if (PointCloumnID == int.Parse(SiteGetColumnLvMyDt.Rows[i]["CX_Column_id"].ToString()))//如果是当前层，则显示自己的级别
                {
                    SiteGetColumnLvss = SiteGetColumnLvii;
                    break;
                }
                else
                {
                    SiteGetColumnLvii = SiteGetColumnLvii + 1;
                    SiteGetColumnLv(int.Parse(SiteGetColumnLvMyDt.Rows[i]["CX_Column_id"].ToString()), PointCloumnID);//调用自己显示自己的级别
                    SiteGetColumnLvii -= 1;
                }
            }
            return SiteGetColumnLvss;


        }

        #region get http web
        /// <summary>
        /// HttpWebRequest读取网页 
        /// </summary>
        /// <param name="website">url</param>
        /// <returns></returns>
        public string GetWeb(string website)
        {
            string strHtmlContent = "";
            try
            {
                if (website.IndexOf("http://") == -1)//如果米有HTTP
                {
                    website = "http://" + TextData.Res.Request.Url.Authority + website;
                }
                System.Net.HttpWebRequest myrequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(website);
                myrequest.Timeout = 600000;//超时时间 10 分钟
                // myrequest.Headers.Set("Pragma", "no-cache");
                System.Net.HttpWebResponse myresponse = (System.Net.HttpWebResponse)myrequest.GetResponse();
                System.IO.Stream mystream = myresponse.GetResponseStream();
                System.Text.Encoding myencoding = System.Text.Encoding.GetEncoding("utf-8");
                System.IO.StreamReader mystreamreader = new System.IO.StreamReader(mystream, myencoding);
                strHtmlContent = mystreamreader.ReadToEnd();
                mystream.Close();
                mystreamreader.Dispose();
                mystream.Close();
                mystream.Dispose();

            }
            catch (Exception ex)
            {
               
            }

            return strHtmlContent;
        }

        /// <summary>
        /// 读取网页 数据 返回生成静态页面的路径
        /// </summary>
        /// <param name="GetURL">要读取数据的网页</param>
        /// <param name="WillWriteUrl">要写入数据的路径 绝对</param>
        /// <returns></returns>
        public String GetWebDataWrite(string GetURL, string WillWriteUrl)
        {

            StreamWriter FileWrite = new StreamWriter(WillWriteUrl, false, System.Text.Encoding.UTF8);
           // FileWrite.Write(System.Text.RegularExpressions.Regex.Replace(GetWeb(GetURL), @"id=""__VIEWSTATE""value=[^<>]+={1,}[""]?", "", System.Text.RegularExpressions.RegexOptions.Multiline)); FileWrite.Flush();//把View保存的东东干掉
            FileWrite.Write(GetWeb(GetURL));
            FileWrite.Flush();//把View保存的东东干掉
            FileWrite.Close();
            FileWrite.Dispose();
            FileWrite = null;

            
            return WillWriteUrl;
        }

        #endregion
    }



}